package me.zk.practice1.hw;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class HWBJJ25 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        List<List<Integer>> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(new ArrayList<>());
        }
        while (scanner.hasNext()) {
            String s = scanner.nextLine();
            if ("1".equals(s)) {
                break;
            }
            int[] a = Arrays.stream(s.split(" ")).mapToInt(Integer::parseInt).toArray();
            list.get(a[0]).add(a[1]);
        }
        //求是否有环
        boolean[] visit = new boolean[n];

        for (int i = 0; i < n; i++) {
            if (findCycle(visit,list,i)) {
                System.out.println("no");
                return;
            }
        }
        System.out.println("yes");
    }

    public static boolean findCycle(boolean[] visit,List<List<Integer>> list,int node) {
        if (visit[node]) {
            return true;
        }
        visit[node] = true;
        for (int n : list.get(node)) {
            if (findCycle(visit,list,n)){
                return true;
            }

        }
        visit[node] = false;
        return false;
    }
}
